home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / mis_bnch / cpu_test / cputest.asm next >
Assembly Source File  |  1993-10-06  |  13KB  |  350 lines

  1. ;
  2. ; CPUTEST.ASM - Copyright (C) 1993 - Tony Doimeadios - All Rights Reserved
  3. ;
  4. ;         Made-----------: 09/30/93
  5. ;         Last Modified--: 10/01/93
  6. ;
  7. ;         This sub will move memory, to time the CPU "speed"
  8. ;         Moving 8,000,000 bytes, 25,000 at a time (80 times)
  9. ;
  10.     
  11.     DOSSEG
  12.     .MODEL LARGE
  13.     .STACK
  14.     .DATA?
  15. Buffer1 db  25000 DUP (?)       ;buffer to copy from
  16. Buffer2 db  25000 DUP (?)       ;buffer to copy to
  17.  
  18.     .DATA
  19. StartLow    dw  0               ;variable to store the low word of start ticks
  20. FinishLow   dw  0               ;variable to store the low word of stop ticks
  21. Counter     dw  0               ;variable to store loop counter
  22. Dummy       dw  0               ;dummy word variable for variable-2-reg proc
  23.  
  24.             ;1234567890123456789012345678901234567890123456789012
  25. Output1  db 'It took       timer ticks to move 8 million bytes...',13,10,'$'
  26. Output2  db 'It took       timer ticks to do 8 million register-to-register moves...',13,10,'$'
  27. Output3  db 'It took       timer ticks to do 8 million variable-to-register moves...',13,10,'$'
  28. Output4  db 'It took       timer ticks to move 100 million bytes...',13,10,'$'
  29.     
  30.     .CODE
  31.     mov ax,@Data
  32.     mov ds,ax                   ;set DS to point to the data segment
  33.  
  34.  
  35. ;---------------------------------------------------------------------
  36.     ;MEMORY MOVES
  37.     ;
  38.     ;timing loop
  39.     ;
  40.     xor  AX,AX                  ;look at the low system timer byte
  41.     int 1Ah                      ;how many clock ticks since midnight
  42.     mov StartLow,dx             ;save it (low word)
  43.     
  44.     
  45.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  46.     mov Counter,0               ;initialize the loop counter
  47.  
  48. DoIt1:    
  49.     call MoveBytes              ;call the memory mover proc
  50.     inc Counter                 ;inc the counter
  51.     cmp Counter,40*8            ;40 loops = 1 million
  52.     jne DoIt1                   ;if it's not the required # of loops, do more
  53.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  54.  
  55.  
  56.     ;timing loop
  57.     ;
  58.     xor  AX,AX                  ;look at the low system timer byte
  59.     int 1Ah                      ;how many clock ticks since midnight
  60.     mov FinishLow,dx            ;save it (low word)
  61.  
  62.  
  63.     ;get difference from start and stop times
  64.     ;
  65.     xor ax,ax                   ;zero out register
  66.     mov ax,FinishLow            ;put stop times in
  67.     sub ax,StartLow             ;sub start from it - ax now holds difference
  68.  
  69.     mov bx,SEG Output1          ;get segment of Output1 string
  70.     mov ds,bx                   ;put it in ds
  71.     mov bx,OFFSET Output1+12    ;offset is 13 characters into the string
  72.     mov cx,5                    ;convert 5 digits
  73.     call Num2Str
  74.  
  75.     mov bx,SEG Output1          ;get segment of Output1 string
  76.     mov ds,bx                   ;put it in ds
  77.     mov bx,Offset Output1       ;get offset of string
  78.     call PrintString            ;print string
  79. ;---------------------------------------------------------------------
  80. ;---------------------------------------------------------------------
  81.  
  82.  
  83.  
  84.  
  85. ;---------------------------------------------------------------------
  86. ;---------------------------------------------------------------------
  87.     ;REGISTER TO REGISTER
  88.     ;
  89.     ;timing loop
  90.     ;
  91.     xor ax,ax                   ;look at the low system timer byte
  92.     int 1Ah                      ;how many clock ticks since midnight
  93.     mov StartLow,dx             ;save it (low word)
  94.  
  95.     
  96.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  97.     mov Counter,0               ;initialize the loop counter
  98.  
  99. DoIt2:    
  100.     call MoveReg                ;call the memory mover proc
  101.     inc Counter                 ;inc the counter
  102.     cmp Counter,40*8            ;40 loops = 1 million
  103.     jne DoIt2                   ;if it's not the required # of loops, do more
  104.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  105.  
  106.  
  107.     ;timing loop
  108.     ;
  109.     xor ax,ax                   ;look at the low system timer byte
  110.     int 1Ah                      ;how many clock ticks since midnight
  111.     mov FinishLow,dx            ;save it (low word)
  112.  
  113.  
  114.     ;get difference from start and stop times
  115.     xor ax,ax                   ;zero out register
  116.     mov ax,FinishLow            ;put stop times in
  117.     sub ax,StartLow             ;sub start from it - ax now holds difference
  118.  
  119.     mov bx,SEG Output2          ;get segment of Output1 string
  120.     mov ds,bx                   ;put it in ds
  121.     mov bx,OFFSET Output2+12    ;offset is 13 characters into the string
  122.     mov cx,5                    ;convert 5 digits
  123.     call Num2Str
  124.  
  125.     mov bx,SEG Output2          ;get segment of Output1 string
  126.     mov ds,bx                   ;put it in ds
  127.     mov bx,Offset Output2       ;get offset of string
  128.     call PrintString            ;print string
  129. ;---------------------------------------------------------------------
  130. ;---------------------------------------------------------------------
  131.  
  132.  
  133.  
  134.  
  135. ;---------------------------------------------------------------------
  136. ;---------------------------------------------------------------------
  137.     ;VARIABLE TO REGISTER
  138.     ;
  139.     ;timing loop
  140.     ;
  141.     xor ax,ax                   ;look at the low system timer byte
  142.     int 1Ah                      ;how many clock ticks since midnight
  143.     mov StartLow,dx             ;save it (low word)
  144.  
  145.     
  146.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  147.     mov Counter,0               ;initialize the loop counter
  148.  
  149. DoIt3:    
  150.     call MemReg                ;call the memory mover proc
  151.     inc Counter                 ;inc the counter
  152.     cmp Counter,40*8            ;40 loops = 1 million
  153.     jne DoIt3                   ;if it's not the required # of loops, do more
  154.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  155.  
  156.  
  157.     ;timing loop
  158.     ;
  159.     xor ax,ax                   ;look at the low system timer byte
  160.     int 1Ah                      ;how many clock ticks since midnight
  161.     mov FinishLow,dx            ;save it (low word)
  162.     
  163.     ;get difference from start and stop times
  164.     xor ax,ax                   ;zero out register
  165.     mov ax,FinishLow            ;put stop times in
  166.     sub ax,StartLow             ;sub start from it - ax now holds difference
  167.  
  168.     mov bx,SEG Output3          ;get segment of Output1 string
  169.     mov ds,bx                   ;put it in ds
  170.     mov bx,OFFSET Output3+12    ;offset is 13 characters into the string
  171.     mov cx,5                    ;convert 5 digits
  172.     call Num2Str
  173.  
  174.     mov bx,SEG Output3          ;get segment of Output1 string
  175.     mov ds,bx                   ;put it in ds
  176.     mov bx,Offset Output3       ;get offset of string
  177.     call PrintString            ;print string
  178. ;---------------------------------------------------------------------
  179. ;---------------------------------------------------------------------
  180.  
  181.  
  182.  
  183.  
  184. ;---------------------------------------------------------------------
  185. ;---------------------------------------------------------------------
  186.     ;MEMORY MOVES (requested by Richard)
  187.     ;
  188.     ;timing loop
  189.     ;
  190.     xor ax,ax                   ;look at the low system timer byte
  191.     int 1Ah                      ;how many clock ticks since midnight
  192.     mov StartLow,dx             ;save it (low word)
  193.  
  194.     
  195.     
  196.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  197.     mov Counter,0               ;initialize the loop counter
  198.  
  199. DoIt4:    
  200.     call MoveBytes              ;call the memory mover proc
  201.     inc Counter                 ;inc the counter
  202.     cmp Counter,40*100          ;40 loops = 1 million
  203.     jne DoIt4                   ;if it's not the required # of loops, do more
  204.     ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  205.  
  206.  
  207.     ;timing loop
  208.     ;
  209.     xor ax,ax                   ;look at the low system timer byte
  210.     int 1Ah                      ;how many clock ticks since midnight
  211.     mov FinishLow,dx            ;save it (low word)
  212.  
  213.  
  214.     ;get difference from start and stop times
  215.     ;
  216.     xor ax,ax                   ;zero out register
  217.     mov ax,FinishLow            ;put stop times in
  218.     sub ax,StartLow             ;sub start from it - ax now holds difference
  219.  
  220.     mov bx,SEG Output4          ;get segment of Output1 string
  221.     mov ds,bx                   ;put it in ds
  222.     mov bx,OFFSET Output4+12    ;offset is 13 characters into the string
  223.     mov cx,5                    ;convert 5 digits
  224.     call Num2Str
  225.  
  226.     mov bx,SEG Output4          ;get segment of Output1 string
  227.     mov ds,bx                   ;put it in ds
  228.     mov bx,Offset Output4       ;get offset of string
  229.     call PrintString            ;print string
  230.  
  231.     jmp short Done              ;done - bail out
  232. ;---------------------------------------------------------------------
  233. ;---------------------------------------------------------------------
  234.  
  235.  
  236.  
  237.  
  238. ;---------------------------------------------------------------------
  239. ; Subroutine to convert a binary number to a text string.
  240. ;
  241. ; Input:
  242. ;       AX = number to convert
  243. ;       DS:BX = pointer to end of string to store text in
  244. ;       CX = number of digits to convert
  245. ;
  246. ; Output: None
  247. ;
  248. ; Registers destroyed: AX, BX, CX, DX, SI
  249. ;
  250. Num2Str   PROC
  251.         mov     si,10                      ;used to divide by 10
  252. ConvertLoop:
  253.         sub     dx,dx                      ;convert AX to doubleword in DX:AX
  254.         div     si                         ;divide number by 10. Remainder is in
  255.                                            ; DX--this is a one-digit decimal
  256.                                            ; number. Number/10 is in AX
  257.         add     dl,'0'                     ;convert remainder to a text character
  258.         mov     [bx],dl                    ;put this digit in the string
  259.         dec     bx                         ;point to the location for the
  260.                                            ; next most-significant digit
  261.         loop    ConvertLoop                ;do the next digit, if any
  262.         ret
  263. Num2Str   ENDP
  264. ;---------------------------------------------------------------------
  265.  
  266.  
  267. ;---------------------------------------------------------------------
  268. ; Subroutine to print a string on the display.
  269. ;
  270. ; Input:
  271. ;       DS:BX = pointer to string to print
  272. ;
  273. ; Output: None
  274. ;
  275. ; Registers destroyed: None
  276. ;
  277. PrintString     PROC
  278.         push    ax
  279.         push    dx              ;preserve registers in this sub
  280.         mov     ah,9            ;DOS print string function #
  281.         mov     dx,bx           ;point DS:DX to the string to print
  282.         int     21h             ;invoke DOS to print the string
  283.         pop     dx              ;restore registers we changed
  284.         pop     ax              ;
  285.         ret                     ;
  286. PrintString     ENDP
  287. ;---------------------------------------------------------------------
  288.  
  289.  
  290.  
  291.  
  292. ;---------------------------------------------------------------------
  293. MoveBytes PROC
  294.     
  295.     mov ax,SEG Buffer1          ;get segment of ROM BIOS
  296.     mov es,ax                   ;put it in ds
  297.     mov di,OFFSET Buffer1       ;get offset of buffer
  298.  
  299.     mov ax,SEG Buffer2          ;get segment of Buffer2
  300.     mov ds,ax                   ;put it in es
  301.     mov si,0                    ;get offset of buffer
  302.  
  303.     mov cx,25000                ;gonna move 25000 bytes
  304.     rep movsb                   ;do it until cx=0
  305.  
  306.     ret                         ;done - bail out
  307.  
  308. MoveBytes ENDP
  309. ;---------------------------------------------------------------------
  310.  
  311.  
  312.  
  313.  
  314. ;---------------------------------------------------------------------
  315. MoveReg PROC
  316.     mov cx,25000                ;setup for 25000 times
  317.     
  318. MoveLoop:
  319.     mov es,ax                   ;do register to register move
  320.     loop MoveLoop               ;do it 25000 times
  321.  
  322.     ret                         ;done - bail out
  323.  
  324. MoveReg ENDP
  325. ;---------------------------------------------------------------------
  326.  
  327.  
  328.  
  329.  
  330. ;---------------------------------------------------------------------
  331. MemReg PROC
  332.     mov cx,25000                ;setup for 25000 times
  333.     
  334. MemLoop:
  335.     mov dx,Dummy                ;do variable to register move
  336.     loop MemLoop                ;do it 25000 times
  337.  
  338.     ret                         ;done - bail out
  339.  
  340. MemReg ENDP
  341. ;---------------------------------------------------------------------
  342.  
  343.  
  344.  
  345.  
  346. Done:
  347.     mov ax,4C00h
  348.     int 21h
  349.     END
  350.